//
//  HESecurityManage.m
//  HealthFamily
//
//  Created by 吴欧 on 2021/2/23.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HESecurityManage.h"
#import "HEGesturesPWDViewController.h"
#import "HETouchID.h"
#import "HETouchIDViewController.h"

@implementation HESecurityManage

+ (BOOL)security {
    
    BOOL hasGesture = [HESecurtyChainData isSave];
    BOOL hasFingerprint = [HESecurtyChainData hasFingerprint];

    // 有手势密码，则跳转到手势密码页
    if (hasGesture) {
        HEGesturesPWDViewController *vc = [[HEGesturesPWDViewController alloc] init];
        vc.gestureModel = HEGesturesPasswordModelValidate;
        kAppDelegate.window.rootViewController = vc;
    }else {
        HEBaseNavigationController *nav = [[HEBaseNavigationController alloc] initWithRootViewController:[[HETouchIDViewController alloc] init]];
        kAppDelegate.window.rootViewController = nav;
    }
    
    if (hasFingerprint) {
        [[HETouchID sharedInstance] td_showTouchIDWithDescribe:nil BlockState:^(HETouchIDState state, NSError *error) {
            if (state == HETouchIDStateSuccess) {    //TouchID/FaceID验证成功
                [[UserManager sharedUserManager] reloadMain];
            }
        }];
    }
    
    return hasGesture || hasFingerprint;
}
 

@end
